/*
 * This class is for abstract factory method.Users can get three kind of factory by public static Factory buildFactory(KindOfFactory kindOfFactory).
 * 
 * public:
 * 		public static Factory buildFactory(KindOfFactory kindOfFactory);
 * 		public abstract Phone getPhone();
 * 		public abstract Pad getPad();
 * 		public abstract Watch getWatch();
 */
package abstractFactory;

import bean.Pad;
import bean.Phone;
import bean.Watch;

public abstract class Factory {
	//A public static method for users.Users can get one kind of factory from enum  KindOfFactory.
	public static Factory buildFactory(KindOfFactory kindOfFactory)
	{
		//Factory is a interface,all kind of factory implement Factory.
		Factory factory = null;
		switch(kindOfFactory)//switch KindOfFactory and get the factory users need.
		{
		case MiFactory:
			factory = new MiFactory();
			break;
		case AppleFactory:
			factory = new AppleFactory();
			break;
		case SamsungFactory:
			factory = new SamsungFactory();
			break;
		}
		return factory;
	}
	
	//this abstract method is for factory in enum KindOfFactory,the factory have to implement this method to build product
	public abstract Phone getPhone();
	public abstract Pad getPad();
	public abstract Watch getWatch();
}

